package cn.zktr.Personnel.model.service.zhouyongcong.OA;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import com.alibaba.fastjson.JSONObject;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class XlsCSer {
	public JSONObject Xls(File targetFile) {
		jxl.Workbook readwb = null;
		if(targetFile!=null){
			try {
				JSONObject jo = null;
				File file1 = targetFile;
				InputStream instream = new FileInputStream(file1);
				readwb = Workbook.getWorkbook(instream); 
	            Sheet readsheet = readwb.getSheet(0);    
	            int rsColumns = readsheet.getColumns();  
	            int rsRows = readsheet.getRows();    
	            
	            jo = new JSONObject();
	            boolean tex = false;
	            String text = "";
	            for (int i = 0; i < rsRows; i++) {   
	                for (int j = 0; j < rsColumns; j++) {   
	                    Cell cell = readsheet.getCell(j, i);
	                    String c = cell.getContents();
	                    
	                    if(tex) {
	                    	tex = false;
	                    	jo.put(text,c);
	                    	text="";
	                    	System.out.print("——数据：|"+c+"  谨慎");
	                    }
	                    if(!getTEXT(c).equals("")) {
	                    	tex = true;
	                    	text = getTEXT(c);
	                    }
	                }   
	                System.out.println();
	            }
	            readwb.close();
	    		return jo;
			} catch (BiffException | IOException e) {
				e.printStackTrace();
				return null;
			}
	    }
		return null;
	}
	public String getTEXT(String c) {
		String text = "";
		if(c.equals("姓名")) {
        	text = "rsename";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("性别")){
        	text = "rsesex";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("年龄")){
        	text = "rseage";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("身高")){
        	text = "rseshgt";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("身份证号")){
        	text = "rsecard";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("联系电话")){
        	text = "rsephome";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("民族")){
        	text = "rsemz";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("国籍")){
        	text = "rsegj";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("应聘职位")){
        	text = "rsepot";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("理想薪资")){
        	text = "rsexz";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("工作经验")){
        	text = "rseexp";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("电子邮箱")){
        	text = "rseemail";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("学历")){
        	text = "rserfs";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("毕业学校")){
        	text = "rsebiye";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("擅长技术")){
        	text = "rseejs";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("联系地址")){
        	text = "rsedizhi";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("工作经历")){
        	text = "rseexps";
        	System.out.print("找到一个数据|"+c);
        }else if(c.equals("自我评价")){
        	text = "rsejieshao";
        	System.out.print("找到一个数据|"+c);
        }
		return text;
	}
}
